import React from 'react';
import ReactEcharts from '@/components/Echarts';

const TaskLine = ({ data = [] }) => {
    const xValues = data.map(item => item.dateStr);
    const yValues1 = data.map(item => item.doneTaskNum);
    const yValues2 = data.map(item => item.workloadDoneNum);
    return (
        <ReactEcharts
            option={{
                color: ['#597EF7', '#FFA22D'],
                tooltip: {
                    trigger: 'item',
                    formatter: '{a} <br/>{b} : {c}'
                },
                grid: {
                    right: 0
                },
                legend: {
                    x: 24,
                    y: 'top',
                    data: ['任务数', '工作量']
                },
                xAxis: [
                    {
                        type: 'category',
                        name: '',
                        axisLine: {
                            lineStyle: {
                                color: 'rgba(0, 0, 0, 0.1)'
                            }
                        },
                        axisLabel: {
                            color: 'rgba(0, 0, 0, 0.45)'
                        },
                        splitLine: { show: false },
                        axisTick: { show: false },
                        data: xValues
                    }
                ],
                yAxis: [
                    {
                        type: 'value',
                        name: '',
                        axisTick: { show: false },
                        axisLine: { show: false },
                        axisLabel: {
                            interval: 20,
                            formatter: '{value}'
                        }
                    }
                ],
                calculable: true,
                series: [
                    {
                        name: '任务数',
                        type: 'line',
                        smooth: true,
                        data: yValues1
                    },
                    {
                        name: '工作量',
                        type: 'line',
                        smooth: true,
                        data: yValues2
                    }
                ]
            }}
        />
    );
};

export default TaskLine;
